package jp.co.sega.sonic_jump.monthly.sum;

import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.PointF;
import android.graphics.Rect;
import android.graphics.RectF;
import android.util.Log;
import android.view.SurfaceHolder;
import android.os.Build;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.File;
import android.os.Environment;
import android.graphics.Region;
import android.graphics.BitmapFactory;
import android.graphics.Paint;
import android.graphics.ColorFilter;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter;
import android.graphics.LightingColorFilter;
import android.graphics.Typeface;
import java.util.List;
import java.util.ArrayList;

public class Graphics {
    public static final int BOTTOM = 16384;
    public static final int FONT_MEDIUM = 40;
    public static final int FONT_SMALL = 24;
    public static final int FONT_TINY = 20;
    public static final int HCENTER = 512;
    public static final int LEFT = 256;
    public static final int RIGHT = 4096;
    public static final int TOP = 1024;
    public static final int TRANS_MIRROR = 2;
    public static final int TRANS_MIRROR_ROT180 = 1;
    public static final int TRANS_MIRROR_ROT270 = 4;
    public static final int TRANS_MIRROR_ROT90 = 7;
    public static final int TRANS_NONE = 0;
    public static final int TRANS_ROT180 = 3;
    public static final int TRANS_ROT270 = 6;
    public static final int TRANS_ROT90 = 5;
    public static final int VCENTER = 8192;
    final int FLIP_HORIZONTAL = 1;
    final int FLIP_NONE = 0;
    final int FLIP_ROTATE = 3;
    final int FLIP_ROTATE_LEFT = 4;
    final int FLIP_ROTATE_RIGHT = 5;
    final int FLIP_ROTATE_RIGHT_HORIZONTAL = 6;
    final int FLIP_ROTATE_RIGHT_VERTICAL = 7;
    final int FLIP_VERTICAL = 2;
    private final int TRANS_Z = 4;
    public Bitmap b = null;
    public Canvas canvas = null;
    private boolean clipFlag = false;
    private int colofARGB = 20;
    private Rect dst = new Rect();
    private float fontSize = 20.0f;
    private int font_size = 12;
    public Canvas g = null;
    private int height = 0;
    private SurfaceHolder holder = null;
    private Matrix mMatrix = new Matrix();
    int ox = 0;
    int oy = 0;
    public Paint p = null;
    public Paint p2 = null;
    private final RectF r2 = new RectF();
    private Rect rect = new Rect();
    private RectF rectF = new RectF();
    private int setFlipMode = 0;
    private Rect src = new Rect();
    private final PointF texAnchor = new PointF();
    private int width = 0;
    public static BitmapFont big;
    public static BitmapFont small;
    public static BitmapFont bitmapFont;
    public Typeface ch;
    public Typeface jp;
    public static boolean bignum = false;
    public Bitmap big6;
    public static boolean customfonts = true;
    public static boolean middle = false;
    
    Graphics(int width2, int height2, int ox2, int oy2) {
        this.width = width2;
        this.height = height2;
        this.ox = ox2;
        this.oy = oy2;
        try {
            this.b = Bitmap.createBitmap(width2, height2, Bitmap.Config.ARGB_8888);
        } catch (Exception e) {
            Log.v("Game", e.toString());
            Log.v("Game", String.valueOf(width2) + "  " + height2);
            Log.v("Game", "?????????????????????");
        }
        this.g = new Canvas(this.b);
        /*this.p = new Paint(3);
        this.p2 = new Paint(3);*/
        this.p = new Paint(Paint.ANTI_ALIAS_FLAG);
        this.p2 = new Paint(/*Paint.ANTI_ALIAS_FLAG*/);
        p.setFilterBitmap(false);
        p.setAntiAlias(true);
        p2.setFilterBitmap(false);
        p2.setAntiAlias(false/*true*/);
        this.p.clearShadowLayer();
        this.p2.clearShadowLayer();
        try {
        List<BitmapFont.BitmapEntry> entries = new ArrayList<>();
        Bitmap regular1 = BitmapFactory.decodeStream(Shell.sInstance.getAssets().open("fonts/regular-font1.png"));
        Bitmap regular2 = BitmapFactory.decodeStream(Shell.sInstance.getAssets().open("fonts/regular-font2.png"));
        Bitmap regular3 = BitmapFactory.decodeStream(Shell.sInstance.getAssets().open("fonts/regular-font3.png"));
        Bitmap regular4 = BitmapFactory.decodeStream(Shell.sInstance.getAssets().open("fonts/regular-font4.png"));
        Bitmap regular5 = BitmapFactory.decodeStream(Shell.sInstance.getAssets().open("fonts/regular-font5.png"));
        Bitmap big1 = BitmapFactory.decodeStream(Shell.sInstance.getAssets().open("fonts/big-font1.png"));
        Bitmap big2 = BitmapFactory.decodeStream(Shell.sInstance.getAssets().open("fonts/big-font2.png"));
        Bitmap big3 = BitmapFactory.decodeStream(Shell.sInstance.getAssets().open("fonts/big-font3.png"));
        Bitmap big4 = BitmapFactory.decodeStream(Shell.sInstance.getAssets().open("fonts/big-font4.png"));
        Bitmap big5 = BitmapFactory.decodeStream(Shell.sInstance.getAssets().open("fonts/big-font5.png"));
        big6 = BitmapFactory.decodeStream(Shell.sInstance.getAssets().open("fonts/big-font6.png"));
        entries.add(new BitmapFont.BitmapEntry(regular1, "abcdefghijklmnopqrstuvwxyz0123456789¡,¿./@*&-!#'()=:?~", 14, 14, 27));
        entries.add(new BitmapFont.BitmapEntry(regular2, "áàäâãéèëêẽóòöôõúùüûũñ", 14, 20, 21));
        entries.add(new BitmapFont.BitmapEntry(regular3, "íì", 12, 20, 2));
        entries.add(new BitmapFont.BitmapEntry(regular4, "ç", 14, 21, 1));
        entries.add(new BitmapFont.BitmapEntry(regular5, "\"’", 13, 28, 2));
        entries.add(new BitmapFont.BitmapEntry(big1, "ABCDEFGHJKLNOSTUVRXYZ", 18, 22, 21));
        entries.add(new BitmapFont.BitmapEntry(big2, "MWPQI", 23, 22, 5));
        entries.add(new BitmapFont.BitmapEntry(big3, "ÁÀÄÂÃÉÈËÊẼÓÒÖÔÕÚÙÜÛŨÑ", 14, 28, 21));
        entries.add(new BitmapFont.BitmapEntry(big4, "ÍÌ", 12, 28, 2));
        entries.add(new BitmapFont.BitmapEntry(big5, "Ç", 15, 29, 2));
        entries.add(new BitmapFont.BitmapEntry(big6, "0123456789:!¡", 17, 22, 13));
        big = new BitmapFont(entries, true);
        
        List<BitmapFont.BitmapEntry> entries2 = new ArrayList<>();
        Bitmap small1 = BitmapFactory.decodeStream(Shell.sInstance.getAssets().open("fonts/small-font1.png")); //10x18 24
        Bitmap small2 = BitmapFactory.decodeStream(Shell.sInstance.getAssets().open("fonts/small-font2.png")); //8x18 10
        Bitmap small3 = BitmapFactory.decodeStream(Shell.sInstance.getAssets().open("fonts/small-font3.png")); //12x18 9
        Bitmap small4 = BitmapFactory.decodeStream(Shell.sInstance.getAssets().open("fonts/small-font4.png")); //4x18 4
        Bitmap small5 = BitmapFactory.decodeStream(Shell.sInstance.getAssets().open("fonts/small-font5.png")); //6x18 6
        Bitmap small6 = BitmapFactory.decodeStream(Shell.sInstance.getAssets().open("fonts/small-font6.png")); //18x18 1
        Bitmap small7 = BitmapFactory.decodeStream(Shell.sInstance.getAssets().open("fonts/small-font7.png")); //14x18 2
        Bitmap small8 = BitmapFactory.decodeStream(Shell.sInstance.getAssets().open("fonts/small-font8.png")); //10x23 12
        Bitmap small9 = BitmapFactory.decodeStream(Shell.sInstance.getAssets().open("fonts/small-font9.png")); //8x23 4
        Bitmap small10 = BitmapFactory.decodeStream(Shell.sInstance.getAssets().open("fonts/small-font10.png")); //11x23 5
        Bitmap small11 = BitmapFactory.decodeStream(Shell.sInstance.getAssets().open("fonts/small-font11.png")); //8x21 2
        Bitmap small12 = BitmapFactory.decodeStream(Shell.sInstance.getAssets().open("fonts/small-font12.png")); //14x18 1
        entries2.add(new BitmapFont.BitmapEntry(small1, "ABCDGHJKNOPRUZ02356789/Ç", 10, 22, 24));
        entries2.add(new BitmapFont.BitmapEntry(small2, "EFILSTXY1\"", 8, 18, 10));
        entries2.add(new BitmapFont.BitmapEntry(small3, "MQVW4¿?*#", 12, 18, 9));
        entries2.add(new BitmapFont.BitmapEntry(small4, "I!':’", 4, 18, 5));
        entries2.add(new BitmapFont.BitmapEntry(small5, ",.-()=", 6, 18, 6));
        entries2.add(new BitmapFont.BitmapEntry(small6, "©", 18, 18, 1));
        entries2.add(new BitmapFont.BitmapEntry(small7, "@&", 14, 18, 2));
        entries2.add(new BitmapFont.BitmapEntry(small8, "ÁÀÄÂÓÒÖÔÚÙÜÛ", 10, 23, 12));
        entries2.add(new BitmapFont.BitmapEntry(small9, "ÉÈËÊ", 8, 23, 4));
        entries2.add(new BitmapFont.BitmapEntry(small10, "ÃẼÕŨÑ", 11, 23, 5));
        entries2.add(new BitmapFont.BitmapEntry(small11, "ÍÌ", 8, 21, 2));
        entries2.add(new BitmapFont.BitmapEntry(small12, "¡", 14, 18, 1));
        small = new BitmapFont(entries2, false);
        } catch (IOException e) {
        }
    }
    
    public Bitmap getB6() {
    return big6;
    }
    
public void drawTextBFont(String text, float x, float y, Paint paint) {
    boolean z = customfonts && !Game_Draw.CurrentL.equals("ch") && !Game_Draw.CurrentL.equals("jp") && Game_Draw.RegularFont && !text.equals("©SEGA") && !text.equals("日本語") && !text.equals("简体中文");
    text = z ? text.toLowerCase() : text;
    if (customfonts) bitmapFont = Game_Draw.BigFont ? big : small;
    if (!customfonts || Game_Draw.CurrentL.equals("ch") || Game_Draw.CurrentL.equals("jp") || bitmapFont == null || text.equals("©SEGA") || text.equals("日本語") || text.equals("简体中文") || !isTextCompatible(text, bitmapFont)) {
    //int originalColor = this.p.getColor();
        /*if (!Game_Draw.BigFont) {
            this.p.setColor(Color.BLACK);
            this.g.drawText(text, x + 2, y + 2, this.p);
            this.p.setColor(originalColor);
            this.g.drawText(text, x, y, this.p);
            return;
        }*/
        /*this.p.setColor(Color.BLACK);
        this.g.drawText(text, x + 1, y + 1, this.p);
        this.g.drawText(text, x - 1, y - 1, this.p);
        this.g.drawText(text, x + 1, y, this.p);
        this.g.drawText(text, x, y + 1, this.p);
        this.g.drawText(text, x - 1, y, this.p);
        this.g.drawText(text, x, y - 1, this.p);
        this.p.setColor(originalColor);*/
        p.setTypeface(null);
        p.setTextSize(getFontSize());
        this.g.drawText(text, x, y, this.p);
        return;
    }
    if (!middle && z) {
    middle = true;
    p.setTypeface(Typeface.createFromAsset(Shell.sInstance.getAssets(), "middle.ttf"));
    p.setTextSize(getFontSize() * 0.7f);
    } else if (text.equals("©SEGA") || middle && !Game_Draw.RegularFont) {
    middle = false;
    p.setTypeface(null);
    p.setTextSize(getFontSize());
    }
    float totalWidth = 0;
    for (int i = 0; i < text.length(); i++) {
        char c = text.charAt(i);
        if (!Game_Draw.RegularFont && Game_Draw.BigFont && (c == ':' || c == '!' || c == '¡' || Character.isDigit(c))) {
        bignum = true;
        }
        BitmapFont.CharInfo ci = bitmapFont.getCharInfo(c);
        BitmapFont.BitmapEntry entry = BitmapFont.BitmapEntry.getBitmapEntryForChar(bitmapFont, c);
        if ((ci == null || entry == null) && c != ' ' && c != '\n') {
            totalWidth += paint.measureText(String.valueOf(c));
        } else {
            float scaleX = 1.0f;
            totalWidth += (c == ' ' || c == '\n') ? Game_Draw.BigFont ? Game_Draw.RegularFont ? 6 : 12 : 10 : ci.advanceWidth * scaleX;
        }
    }

    float cursorX = Game_Draw.FontRightAdjust ? x - totalWidth : Game_Draw.BigFont && !Game_Draw.RegularFont || Game_Draw.FontAdjust ? x - totalWidth / 2f : x;
    float baseY = !Game_Draw.BigFont && !Game_Draw.FontAdjust ? Game_Draw.helpAdjust ? y - 20f : Game_Draw.tutAdjust ? y - 9f : y : Game_Draw.RegularFont ? y -15f : y - 20f;

    for (int i = 0; i < text.length(); i++) {
        char c = text.charAt(i);
        BitmapFont.CharInfo charInfo = bitmapFont.getCharInfo(c);
        BitmapFont.BitmapEntry entry = BitmapFont.BitmapEntry.getBitmapEntryForChar(bitmapFont, c);

        if ((charInfo == null || entry == null) && c != ' ' && c != '\n') {
            /*String s = String.valueOf(c);
            int originalColor = getColor();
            paint.setTextSize(getFontSize());
            int i2 = 14;

            if (!Game_Draw.BigFont) {
                paint.setColor(Color.BLACK);
                this.g.drawText(s, cursorX + i2 + 2, y + 2, paint);
                paint.setColor(originalColor);
                this.g.drawText(s, cursorX + i2, y, paint);
            } else {
                paint.setColor(Color.BLACK);
                this.g.drawText(s, cursorX + i2 + 1, y + 1, paint);
                this.g.drawText(s, cursorX + i2 - 1, y - 1, paint);
                this.g.drawText(s, cursorX + i2 + 1, y, paint);
                this.g.drawText(s, cursorX + i2, y + 1, paint);
                this.g.drawText(s, cursorX + i2 - 1, y, paint);
                this.g.drawText(s, cursorX + i2, y - 1, paint);
                paint.setColor(originalColor);
                this.g.drawText(s, cursorX + i2, y, paint);
            }
            cursorX += paint.measureText(s);*/
            continue;
        }

        float scaleX = 1.0f;
        float scaleY = 1.0f;

        if (charInfo.base != null) {
            Bitmap baseBitmap = charInfo.base.bitmap;
            Rect srcBase = charInfo.base.rect;
            RectF dstBase = new RectF(
                cursorX,
                baseY + charInfo.OffsetY * scaleY,
                cursorX + entry.charWidth * scaleX,
                baseY + charInfo.OffsetY * scaleY + entry.charHeight * scaleY
            );
            this.g.drawBitmap(baseBitmap, srcBase, dstBase, paint);
        }
        if (charInfo.diacritic != null) {
            Bitmap diacriticBitmap = charInfo.diacritic.bitmap;
            Rect srcDiacritic = charInfo.diacritic.rect;
            RectF dstDiacritic = new RectF(
                cursorX + charInfo.OffsetX * scaleX,
                baseY + charInfo.OffsetY * scaleY,
                cursorX + charInfo.OffsetX * scaleX + entry.charWidth * scaleX,
                baseY + charInfo.OffsetY * scaleY + entry.charHeight * scaleY
            );
            this.g.drawBitmap(diacriticBitmap, srcDiacritic, dstDiacritic, paint);
        }
        cursorX += (c == ' ' || c == '\n') ? Game_Draw.BigFont ? Game_Draw.RegularFont ? 6 : 12 : 10 : charInfo.advanceWidth * scaleX;
    }
    if (bignum) bignum = false;
}
    public boolean isTextCompatible(String text, BitmapFont bitmapFont) {
    for (int i = 0; i < text.length(); i++) {
        if (bitmapFont.getCharInfo(text.charAt(i)) == null) {
            return false;
        }
    }
    return true;
}
    
    public final Matrix getM() {
        return this.mMatrix;
    }
    public final Canvas getCanvas() {
        return this.g;
    }
    public final Paint getP() {
        return this.p;
    }

    /* access modifiers changed from: package-private */
    public final void lock(SurfaceHolder holder2) {
        if (holder2 != null) {
            this.holder = holder2;
            this.canvas = this.holder.lockCanvas();
        }
    }

    /* access modifiers changed from: package-private */
    public final void unlock(boolean bool) {
        if (bool && this.canvas != null && this.holder != null && this.b != null && this.p != null) {
            this.canvas.drawBitmap(this.b, 0.0f, 0.0f, this.p);
            this.holder.unlockCanvasAndPost(this.canvas);
        }
    }

    /* access modifiers changed from: package-private */
    public final void setFlipMode(int type) {
        this.setFlipMode = type;
    }

    /* access modifiers changed from: package-private */
    public final void setFont(int font) {
        if (this.font_size != font) {
            Paint paint = this.p;
            this.font_size = font;
            paint.setTextSize((float) font);
        }
    }

    /* access modifiers changed from: package-private */
    public final int getFontSize() {
        return this.font_size;
    }

    /* access modifiers changed from: package-private */
    public final void setClip(int sx, int sy, int ex, int ey) {
        try {
        if (this.clipFlag) {
            this.g.restore();
            this.clipFlag = false;
        }
        this.g.save(/*2*/);
        this.g.clipRect(sx, sy, ex + sx, ey + sy);
        this.clipFlag = true;
        } catch (Exception e) {
        }
    }

    /* access modifiers changed from: package-private */
    public final void clearClip() {
        try {
        if (this.clipFlag) {
            this.g.restore();
            this.clipFlag = false;
        }
        } catch (Exception e) {
        }
    }

    public final void setColor2(int argb) {
        int alpha = (int) (((double) (argb >> 24)) * 2.55d);
        if (alpha >= 254) {
            alpha = 255;
        }
        int color = Color.argb(alpha, (argb >> 16) & 255, (argb >> 8) & 255, argb & 255);
        this.p.setColor(color);
        this.p2.setColorFilter(new LightingColorFilter(color, 0x000000));
    }

    public final int getColor() {
        return this.p.getColor();
    }

    /* access modifiers changed from: package-private */
    public final void setAlpha(int alpha) {
        int alpha2 = (int) (((float) alpha) * 2.55f);
        if (alpha2 >= 254) {
            alpha2 = 255;
        }
        this.p.setColor(Color.argb(alpha2, 0, 0, 0));
    }

    public final void drawLine(int sx, int sy, int ex, int ey) {
        this.p.setStyle(Paint.Style.FILL_AND_STROKE);
        this.p.setStrokeWidth(1.0f);
        Path path = new Path();
        path.moveTo((float) (this.ox + sx), (float) (this.oy + sy));
        path.lineTo((float) (this.ox + ex), (float) (this.oy + ey));
        this.g.drawPath(path, this.p);
    }

    public final void drawRect(Rect rect2) {
        this.p.setStyle(Paint.Style.STROKE);
        this.p.setStrokeWidth(1.0f);
        this.g.drawRect(rect2, this.p);
    }

    public final void drawRect(int sx, int sy, int ex, int ey) {
        this.p.setStyle(Paint.Style.STROKE);
        this.p.setStrokeWidth(1.0f);
        this.rect.left = this.ox + sx;
        this.rect.top = this.oy + sy;
        this.rect.right = ex + sx + this.ox;
        this.rect.bottom = ey + sy + this.oy;
        this.g.drawRect(this.rect, this.p);
    }

    public final void fillRect(int sx, int sy, int ex, int ey) {
        this.p.setStyle(Paint.Style.FILL);
        this.p.setStrokeWidth(1.0f);
        this.rect.left = this.ox + sx;
        this.rect.top = this.oy + sy;
        this.rect.right = ex + sx + this.ox + 1;
        this.rect.bottom = ey + sy + this.oy + 1;
        this.g.drawRect(this.rect, this.p);
    }

    /* access modifiers changed from: package-private */
    public final void fillArc(int sx, int sy, int ex, int ey) {
        this.p.setStyle(Paint.Style.FILL);
        this.p.setStrokeWidth(1.0f);
        this.rectF.left = (float) (this.ox + sx);
        this.rectF.top = (float) (this.oy + sy);
        this.rectF.right = (float) (ex + sx);
        this.rectF.bottom = (float) (ey + sy);
        this.g.drawArc(this.rectF, 0.0f, 360.0f, false, this.p);
    }

    public final void fillArc(int sx, int sy, int ex, int ey, int start, int end) {
        this.p.setStyle(Paint.Style.FILL);
        this.p.setStrokeWidth(1.0f);
        this.rectF.left = (float) (this.ox + sx);
        this.rectF.top = (float) (this.oy + sy);
        this.rectF.right = (float) (ex + sx);
        this.rectF.bottom = (float) (ey + sy);
        this.g.drawArc(this.rectF, (float) start, (float) end, false, this.p);
    }

    /* access modifiers changed from: package-private */
    public final void drawArc(int sx, int sy, int ex, int ey) {
        this.p.setStyle(Paint.Style.STROKE);
        this.p.setStrokeWidth(1.0f);
        this.rectF.left = (float) (this.ox + sx);
        this.rectF.top = (float) (this.oy + sy);
        this.rectF.right = (float) (ex + sx);
        this.rectF.bottom = (float) (ey + sy);
        this.g.drawArc(this.rectF, 0.0f, 360.0f, false, this.p);
    }

    /* access modifiers changed from: package-private */
    public final void drawArc(int sx, int sy, int ex, int ey, int start, int end) {
        this.p.setStyle(Paint.Style.STROKE);
        this.p.setStrokeWidth(1.0f);
        this.rectF.left = (float) (this.ox + sx);
        this.rectF.top = (float) (this.oy + sy);
        this.rectF.right = (float) (ex + sx);
        this.rectF.bottom = (float) (ey + sy);
        this.g.drawArc(this.rectF, (float) start, (float) end, false, this.p);
    }

    public final void drawRoundRect(int sx, int sy, int ex, int ey, int rx, int ry) {
        this.p.setStyle(Paint.Style.STROKE);
        this.p.setStrokeWidth(1.0f);
        this.rectF.left = (float) (this.ox + sx);
        this.rectF.top = (float) (this.oy + sy);
        this.rectF.right = (float) (ex + sx + this.ox);
        this.rectF.bottom = (float) (ey + sy + this.oy);
        this.g.drawRoundRect(this.rectF, (float) rx, (float) ry, this.p);
    }

    public final void fillRoundRect(int sx, int sy, int ex, int ey, int rx, int ry) {
        this.p.setStyle(Paint.Style.FILL);
        this.p.setStrokeWidth(1.0f);
        this.rectF.left = (float) (this.ox + sx);
        this.rectF.top = (float) (this.oy + sy);
        this.rectF.right = (float) (ex + sx + this.ox);
        this.rectF.bottom = (float) (ey + sy + this.oy);
        this.g.drawRoundRect(this.rectF, (float) rx, (float) ry, this.p);
    }

    /* access modifiers changed from: package-private */
    public final void drawString(String string, int px, int py) {
        this.p.setStyle(Paint.Style.FILL);
        this.p.setStrokeWidth(1.0f);
        this.p2.setStyle(Paint.Style.FILL);
        this.p2.setStrokeWidth(1.0f);
        try {
        if (Game_Draw.CurrentL.equals("jp")) {
        jp = Typeface.createFromAsset(Shell.sInstance.getAssets(), "jpfont.ttf");
        p.setTypeface(jp);
        } else if (Game_Draw.CurrentL.equals("ch")) {
        ch = Typeface.createFromAsset(Shell.sInstance.getAssets(), "chfont.ttf");
        p.setTypeface(ch);
        }
        } catch (Exception e) {
        try {
        p.setTypeface(Typeface.createFromAsset(Shell.sInstance.getAssets(), "default.ttf"));
        p.setTextSize(getFontSize() * 0.9f);
        } catch (Exception e2) {
        p.setTypeface(null);
        p.setTextSize(getFontSize());
        }
        }
        //p.setFakeBoldText(true);
        float x = (float) (this.ox + px);
        float y = (float) (((getFontSize() + py) + this.oy) - 2);
        /*this.g.*/drawTextBFont(string, x, y, this.p2);
    }

    public final void drawString(String string, float px, float py, int anchor) {
        this.p.setStyle(Paint.Style.FILL);
        this.p.setStrokeWidth(1.0f);
        this.p2.setStyle(Paint.Style.FILL);
        this.p2.setStrokeWidth(1.0f);
        if ((anchor & HCENTER) != 0) {
            this.p.setTextAlign(Paint.Align.CENTER);
            this.p2.setTextAlign(Paint.Align.CENTER);
        } else if ((anchor & RIGHT) != 0) {
            this.p.setTextAlign(Paint.Align.RIGHT);
            this.p2.setTextAlign(Paint.Align.RIGHT);
        } else {
            this.p.setTextAlign(Paint.Align.LEFT);
            this.p2.setTextAlign(Paint.Align.LEFT);
        }
        try {
        if (Game_Draw.CurrentL.equals("jp")) {
        jp = Typeface.createFromAsset(Shell.sInstance.getAssets(), "jpfont.ttf");
        p.setTypeface(jp);
        } else if (Game_Draw.CurrentL.equals("ch")) {
        ch = Typeface.createFromAsset(Shell.sInstance.getAssets(), "chfont.ttf");
        p.setTypeface(ch);
        }
        } catch (Exception e) {
        try {
        p.setTypeface(Typeface.createFromAsset(Shell.sInstance.getAssets(), "default.ttf"));
        p.setTextSize(getFontSize() * 0.9f);
        } catch (Exception e2) {
        p.setTypeface(null);
        p.setTextSize(getFontSize());
        }
        }
        //p.setFakeBoldText(true);
        float x = px + 0.0f + ((float) this.ox);
        float y = ((float) getFontSize()) + coordinatesY(py, (float) getFontSize(), anchor) + ((float) this.oy);
        /*this.g.*/drawTextBFont(string, x, y, this.p2);
    }

    public final int stringWidth(String string) {
        return (int) this.p.measureText(string);
    }

    public final void drawImage(Bitmap image, float x, float y, int anchor) {
        /*if (Game_Draw.multip) {
        image = Bitmap.createScaledBitmap(image, image.getWidth(), image.getHeight()/2, true);
        }*/
        this.g.drawBitmap(image, ((float) this.ox) + coordinatesX(x, (float) image.getWidth(), anchor), ((float) this.oy) + coordinatesY(y, (float) image.getHeight(), anchor), this.p);
    }

    /* access modifiers changed from: package-private */
    public final void drawImage(Bitmap bitmap, int x, int y) {
        try {
            /*if (Game_Draw.multip) {
        bitmap = Bitmap.createScaledBitmap(bitmap, bitmap.getWidth(), bitmap.getHeight()/2, true);
        }*/
            this.g.drawBitmap(bitmap, (float) (this.ox + x), (float) (this.oy + y), this.p);
        } catch (Exception e) {
        }
    }

    /* access modifiers changed from: package-private */
    public final void drawImage(Bitmap bitmap, int dx, int dy, int sx, int sy, int width2, int height2) {
        switch (this.setFlipMode) {
            case 0:
                drawRegion(bitmap, sx, sy, width2, height2, 0, dx, dy, 1280);
                return;
            case 1:
                drawRegion(bitmap, sx, sy, width2, height2, 2, dx, dy, 1280);
                return;
            case 2:
                drawRegion(bitmap, sx, sy, width2, height2, 1, dx, dy, 1280);
                return;
            case 3:
                drawRegion(bitmap, sx, sy, width2, height2, 3, dx, dy, 1280);
                return;
            case 4:
                drawRegion(bitmap, sx, sy, width2, height2, 6, dx, dy, 1280);
                return;
            case 5:
                drawRegion(bitmap, sx, sy, width2, height2, 5, dx, dy, 1280);
                return;
            case 6:
                drawRegion(bitmap, sx, sy, width2, height2, 0, dx, dy, 1280);
                return;
            case 7:
                drawRegion(bitmap, sx, sy, width2, height2, 0, dx, dy, 1280);
                return;
            default:
                return;
        }
    }

    public void drawRegion(Bitmap img, int x_src, int y_src, int width2, int height2, int transform, int x_dest, int y_dest, int anchor) {
        this.mMatrix.reset();
        int drawWidth = width2;
        int drawHeight = height2;
        int xOffset = 0;
        int yOffset = 0;
        switch (transform) {
            case 0:
                xOffset = -x_src;
                yOffset = -y_src;
                break;
            case 1:
                this.mMatrix.preScale(-1.0f, 1.0f);
                this.mMatrix.preRotate(-180.0f);
                xOffset = -x_src;
                yOffset = drawHeight + y_src;
                break;
            case 2:
                this.mMatrix.preScale(-1.0f, 1.0f);
                xOffset = drawWidth + x_src;
                yOffset = -y_src;
                break;
            case 3:
                this.mMatrix.preRotate(180.0f);
                xOffset = drawWidth + x_src;
                yOffset = drawHeight + y_src;
                break;
            case 4:
                this.mMatrix.preScale(-1.0f, 1.0f);
                this.mMatrix.preRotate(-270.0f);
                drawWidth = height2;
                drawHeight = width2;
                xOffset = -y_src;
                yOffset = -x_src;
                break;
            case 5:
                this.mMatrix.preRotate(90.0f);
                drawWidth = height2;
                drawHeight = width2;
                xOffset = drawWidth + y_src;
                yOffset = -x_src;
                break;
            case 6:
                this.mMatrix.preRotate(270.0f);
                drawWidth = height2;
                drawHeight = width2;
                xOffset = -y_src;
                yOffset = drawHeight + x_src;
                break;
            case 7:
                this.mMatrix.preScale(-1.0f, 1.0f);
                this.mMatrix.preRotate(-90.0f);
                drawWidth = height2;
                drawHeight = width2;
                xOffset = drawWidth + y_src;
                yOffset = drawHeight + x_src;
                break;
        }
        if (anchor == 0) {
            anchor = 1280;
        }
        if ((anchor & BOTTOM) != 0) {
            y_dest -= drawHeight - 1;
        } else if ((anchor & VCENTER) != 0) {
            y_dest -= (drawHeight - 1) >>> 1;
        }
        if ((anchor & RIGHT) != 0) {
            x_dest -= drawWidth - 1;
        } else if ((anchor & HCENTER) != 0) {
            x_dest -= (drawWidth - 1) >>> 1;
        }
        this.g.save();
        this.g.clipRect(x_dest, y_dest, x_dest + drawWidth, y_dest + drawHeight);
        this.g.translate((float) (x_dest + xOffset), (float) (y_dest + yOffset));
        /*if (Game_Draw.multip) {
        img = Bitmap.createScaledBitmap(img, img.getWidth(), img.getHeight()/2, true);
        }*/
        this.g.drawBitmap(img, this.mMatrix, this.p);
        try {
        this.g.restore();
        } catch (Exception e) {
        }
    }

    /* access modifiers changed from: package-private */
    public final void drawRegion2(Bitmap bitmap, int src_sx, int src_sy, int src_ex, int src_ey, int degrees, int dst_sx, int dst_sy, int dst_ex, int dst_ey, int anchor) {
        this.src.left = src_sx;
        this.src.top = src_sy;
        this.src.right = src_ex + src_sx;
        this.src.bottom = src_ey + src_sy;
        int x = (int) coordinatesX((float) dst_sx, (float) dst_ex, anchor);
        int y = (int) coordinatesY((float) dst_sy, (float) dst_ey, anchor);
        this.dst.left = this.ox + x;
        this.dst.top = this.oy + y;
        this.dst.right = src_ex + x + this.ox;
        this.dst.bottom = src_ey + y + this.oy;
        if (degrees != 0) {
            this.g.rotate((float) degrees, (float) (this.dst.left + (dst_ex / 2)), (float) (this.dst.top + (dst_ey / 2)));
        }
        /*if (Game_Draw.multip) {
        bitmap = Bitmap.createScaledBitmap(bitmap, bitmap.getWidth(), bitmap.getHeight()/2, true);
        }*/
        this.g.drawBitmap(bitmap, this.src, this.dst, this.p);
        if (degrees != 0) {
            this.g.rotate((float) (-degrees), (float) (this.dst.left + (dst_ex / 2)), (float) (this.dst.top + (dst_ey / 2)));
        }
    }

    /* access modifiers changed from: package-private */
    public final Bitmap getBitmap() {
        return this.b;
    }

    /* access modifiers changed from: package-private */
    public final int getWidth() {
        return this.width;
    }

    /* access modifiers changed from: package-private */
    public final int getHeight() {
        return this.height;
    }

    private final float coordinatesX(float x, float objectWidth, int anchor) {
        if ((anchor & LEFT) != 0) {
            return x;
        }
        if ((anchor & HCENTER) != 0) {
            return x - (objectWidth / 2.0f);
        }
        if ((anchor & RIGHT) != 0) {
            return x - objectWidth;
        }
        return x;
    }

    private final float coordinatesY(float y, float objectHeight, int anchor) {
        if ((anchor & TOP) != 0) {
            return y;
        }
        if ((anchor & VCENTER) != 0) {
            return y - (objectHeight / 2.0f);
        }
        if ((anchor & BOTTOM) != 0) {
            return y - objectHeight;
        }
        return y;
    }

    private final boolean isHanKana(char c) {
        StringBuffer wkStr = new StringBuffer(new StringBuilder(String.valueOf(c)).toString());
        for (int i = 0; i < wkStr.length(); i++) {
            if (wkStr.charAt(i) >= 65377 && wkStr.charAt(i) <= 65439) {
                return true;
            }
        }
        return false;
    }

    public final void setColor(int rgb) {
        this.colofARGB = (((100 - ((rgb >> 24) & 255)) << 24) & -16777216) + ((((rgb >> 16) & 255) << 16) & Game_Draw.Color_Red) + ((((rgb >> 8) & 255) << 8) & 65280) + (((rgb & 255) << 0) & 255);
        setColor2(this.colofARGB);
    }

    public void setColor(int r, int g2, int b2) {
        setColor(((r << 16) & Game_Draw.Color_Red) + ((g2 << 8) & 65280) + ((b2 << 0) & 255));
    }

    /* access modifiers changed from: package-private */
    public final void wg_drawRegion(Bitmap img, RectF drawRect, RectF getRect, float transform, float angle, float alpha, float anchor) {
        setAlpha((int) alpha);
        drawRegion2(img, (int) getRect.left, (int) getRect.top, (int) getRect.right, (int) getRect.bottom, (int) angle, (int) drawRect.left, (int) drawRect.top, (int) drawRect.right, (int) drawRect.bottom, (int) anchor);
    }

    /* access modifiers changed from: package-private */
    public final void wg_drawRegion(Bitmap img, int sx, int sy, int w, int h, int transform, int dx, int dy, int anchor) {
        this.rectF.left = (float) dx;
        this.rectF.top = (float) dy;
        this.rectF.right = (float) w;
        this.rectF.bottom = (float) h;
        this.r2.left = (float) sx;
        this.r2.top = (float) sy;
        this.r2.right = (float) w;
        this.r2.bottom = (float) h;
        wg_drawRegion(img, this.rectF, this.r2, 4.0f, (float) transform, 100.0f, (float) anchor);
    }

    /* access modifiers changed from: package-private */
    public final void wg_drawRegion(Bitmap img, float x, float y, RectF rect2, int anchor) {
        this.rectF.left = x;
        this.rectF.top = y;
        this.rectF.right = rect2.right;
        this.rectF.bottom = rect2.bottom;
        wg_drawRegion(img, this.rectF, rect2, 0.0f, 0.0f, 100.0f, (float) anchor);
    }

    /* access modifiers changed from: package-private */
    public final void wg_drawRegion(Bitmap img, PointF p2, RectF rect2, int anchor) {
        this.rectF.left = p2.x;
        this.rectF.top = p2.y;
        this.rectF.right = rect2.right;
        this.rectF.bottom = rect2.bottom;
        wg_drawRegion(img, this.rectF, rect2, 0.0f, 0.0f, 100.0f, (float) anchor);
    }

    /* access modifiers changed from: package-private */
    public final void wg_drawRegion(Bitmap img, RectF drawRect, RectF getRect, int alpha, int anchor) {
        wg_drawRegion(img, drawRect, getRect, 0.0f, 0.0f, (float) alpha, (float) anchor);
    }

    public final void wg_drawImage(Bitmap img, float x, float y, int anchor) {
        if (img != null) {
        this.rectF.left = x;
        this.rectF.top = y;
        this.rectF.right = (float) img.getWidth();
        this.rectF.bottom = (float) img.getHeight();
        this.r2.left = 0.0f;
        this.r2.top = 0.0f;
        this.r2.right = (float) img.getWidth();
        this.r2.bottom = (float) img.getHeight();
        wg_drawRegion(img, this.rectF, this.r2, 0.0f, 0.0f, 100.0f, (float) anchor);
        }
    }

    /* access modifiers changed from: package-private */
    public final void wg_drawScaleImage(Bitmap img, PointF point, PointF size, int anchor) {
        setAlpha(100);
        drawRegion2(img, 0, 0, img.getWidth(), img.getHeight(), 0, (int) point.x, (int) point.y, (int) size.x, (int) size.y, anchor);
    }

    /* access modifiers changed from: package-private */
    public final void drawNSString(String str, float x, float y, int anchor) {
        if (str != null) {
            this.texAnchor.x = coordinatesX((float) ((int) x), (float) ((int) (((float) str.length()) * this.fontSize)), anchor);
            this.texAnchor.y = coordinatesY((float) ((int) y), (float) ((int) this.fontSize), anchor);
            drawString(str, (int) this.texAnchor.x, (int) this.texAnchor.y);
        }
    }

    public final void wg_setFontSize(int size) {
        this.fontSize = (float) size;
        setFont(size);
    }

    /* access modifiers changed from: package-private */
    public final void deleteAllTextureData() {
    }

    /* access modifiers changed from: package-private */
    public final void drawTexScaleImage(Bitmap img, RectF drawRect, RectF getRect, int transform, float angle, int alpha, int anchor) {
        setAlpha(alpha);
        drawRegion2(img, (int) getRect.left, (int) getRect.top, (int) getRect.right, (int) getRect.bottom, (int) angle, (int) drawRect.left, (int) drawRect.top, (int) drawRect.right, (int) drawRect.bottom, anchor);
    }

    public int getClipX() {
        Rect rect2 = this.g.getClipBounds();
        if (rect2 != null) {
            return rect2.left;
        }
        return 0;
    }

    public int getClipY() {
        Rect rect2 = this.g.getClipBounds();
        if (rect2 != null) {
            return rect2.top;
        }
        return 0;
    }

    public int getClipWidth() {
        Rect rect2 = this.g.getClipBounds();
        if (rect2 != null) {
            return rect2.right - rect2.left;
        }
        return 0;
    }

    public int getClipHeight() {
        Rect rect2 = this.g.getClipBounds();
        if (rect2 != null) {
            return rect2.bottom - rect2.top;
        }
        return 0;
    }

    public void translate(int x, int y) {
        this.g.translate((float) x, (float) y);
    }
}
